﻿#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <string>
using namespace std;
#include "Hash.h"
#include "UnorderedSet.h"
#include "UnorderedMap.h"
#include "bit_set.h"
#include "bloom_filter.h"

//int main()
//{
//	string arr[] = { "香蕉", "甜瓜", "苹果", "西瓜", "苹果", "西瓜", "苹果", "苹果", "西瓜", "苹果", "香蕉", "苹果", "香蕉" };
//	ether::HashBucket<string, int> ht;
//	for (auto& e : arr)
//	{
//		ether::HashNode<string, int>* ret = ht.find(e);
//		if (ret)
//		{
//			ret->_kv.second++;
//		}
//		else
//		{
//			ht.insert(make_pair(e, 1));
//		}
//	}
//	return 0;
//}

void test_map()
{
	ether::unordered_map<string, string> dict;
	dict.insert(make_pair("sort", "排序"));
	dict.insert(make_pair("string", "字符串"));
	dict.insert(make_pair("insert", "插入"));

	for (auto& kv : dict)
	{
		//kv.second += 'x';

		cout << kv.first << ":" << kv.second << endl;
	}
	cout << endl;

	string arr[] = { "香蕉", "甜瓜", "苹果", "西瓜", "苹果", "西瓜", "苹果", "苹果", "西瓜", "苹果", "香蕉", "苹果", "香蕉" };	
	ether::unordered_map<string, int> count_map;
	for (auto& e : arr)
	{
		count_map[e]++;
	}

	for (auto& kv : count_map)
	{
		cout << kv.first << ":" << kv.second << endl;
	}
	cout << endl;
}

void test_set()
{
	ether::unordered_set<int> us;
	us.insert(5);
	us.insert(15);
	us.insert(52);
	us.insert(3);

	ether::unordered_set<int>::iterator it = us.begin();
	while (it != us.end())
	{
		//*it += 5;
		cout << *it << " ";
		++it;
	}
	cout << endl;

	for (auto e : us)
	{
		cout << e << " ";
	}
	cout << endl;
}

int main()
{
	test_map();
	test_set();
	return 0;
}